package com.clkj.sunhelp.mvp.seekhelp.seekhelphis;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.clkj.sunhelp.R;
import com.clkj.sunhelp.adapter.list.ListAdapterForSeekHelpHis;
import com.clkj.sunhelp.bean.SeekHelpHisListItem;
import com.clkj.sunhelp.mvp.base.BaseActivity;
import com.clkj.sunhelp.mvp.seekhelp.ActivitySeekHelpInfoSubmitView;
import com.clkj.sunhelp.mvp.seekhelp.seekhelpdetail.ActivitySeekHelpDetailView;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/3/27.
 */

public class ActivitySeekHelpHisListView extends BaseActivity implements PullToRefreshBase.OnRefreshListener2,View.OnClickListener{

    private PullToRefreshListView lv;

    private ListView originalLv;


    List<SeekHelpHisListItem> mSeekHelpHisList = new ArrayList<>();

    ListAdapterForSeekHelpHis mAdapter ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seek_help_his_list_view);
        initTitleWithRightTvOrIv(null,null,"求助历史",true,"我要求助",null);
        initData();
        assignView();
        initView();
    }

    @Override
    public void initData() {
        SeekHelpHisListItem seekHelpHisListItem = new SeekHelpHisListItem();
        seekHelpHisListItem.setHuZhuName("张三");
        seekHelpHisListItem.setIdCardNo("320811199004786358");
        seekHelpHisListItem.setApplyProjName("贫困户项目");
        seekHelpHisListItem.setApplyTime("2017-03-27");
        seekHelpHisListItem.setDealState("已受理");

        mSeekHelpHisList.add(seekHelpHisListItem);
        mSeekHelpHisList.add(seekHelpHisListItem);
        mSeekHelpHisList.add(seekHelpHisListItem);
        mSeekHelpHisList.add(seekHelpHisListItem);
        mSeekHelpHisList.add(seekHelpHisListItem);
        mSeekHelpHisList.add(seekHelpHisListItem);
    }

    @Override
    public void assignView() {
        lv = (PullToRefreshListView) findViewById(R.id.lv);
        originalLv = lv.getRefreshableView();
    }

    @Override
    public void initView() {

        tvRight.setOnClickListener(this);

        lv.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
        lv.setOnRefreshListener(this);

        mAdapter = new ListAdapterForSeekHelpHis(this,mSeekHelpHisList);
        originalLv.setAdapter(mAdapter);
        originalLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent toSeekHelpDetail =new Intent(ActivitySeekHelpHisListView.this, ActivitySeekHelpDetailView.class);
                startActivity(toSeekHelpDetail);
            }
        });
    }

    @Override
    public void onPullDownToRefresh(PullToRefreshBase refreshView) {

    }

    @Override
    public void onPullUpToRefresh(PullToRefreshBase refreshView) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId())
        {
            case R.id.tv_right:
                startActivity(new Intent(this, ActivitySeekHelpInfoSubmitView.class));
                break;

        }
    }
}
